package cn.niit.diy;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
//Aop第三种方式  注解

@Aspect
public class AnnotationPointCut {
    final String EXECUTION = "execution(* cn.niit.serivce.impl.UserServiceImpl.*(..))";

    @Before(EXECUTION)
    public void Before() {
        System.out.println("【AnnotationPointCut】前置通知：方法执行前");
    }

    @AfterReturning(EXECUTION)
    public void AfterReturning() {
        System.out.println("【AnnotationPointCut】后置通知：方法执行后");
    }

    @AfterThrowing(EXECUTION)
    public void AfterThrowing() {
        System.out.println("【AnnotationPointCut】异常通知：发生异常后执行");
    }

    @After(EXECUTION)
    public void After() {
        System.out.println("【AnnotationPointCut】最终通知");

    }

    @Around(EXECUTION)
    public Object Around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("【AnnotationPointCut.around()】环绕通知....1111...getSignature: " + joinPoint.getSignature());
        System.out.println("【AnnotationPointCut.around()】环绕通知....222...getArgs：" + joinPoint.getArgs().length);
        joinPoint.proceed();
        System.out.println("【AnnotationPointCut.around()】环绕通知....333..." + joinPoint.getSignature());
        return new Integer(1);
    }
}

